﻿using System.ComponentModel;
using System.Web.Mvc;

namespace RecruitmentAgency.Models
{
    public class RecruitmentAgencyModelBinder : DefaultModelBinder
    { 
        protected override void SetProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor, object value)
        {
            if (propertyDescriptor.PropertyType == typeof(string)) 
            {
                string stringValue = value.ToString();
                if (!string.IsNullOrEmpty(stringValue)) value = stringValue.Trim();
            }
            base.SetProperty(controllerContext, bindingContext, propertyDescriptor, value); 
        }
    }
}